package cn.shyouchi.wuguanjia.android.ui.meetting.plan;

import android.app.Activity;
import android.os.Bundle;

import cn.shyouchi.wuguanjia.android.api.meet.MeetApi;
import cn.shyouchi.wuguanjia.android.model.BaseRequestResult;
import cn.shyouchi.wuguanjia.android.subscribers.ProgressSubscriber;
import cn.shyouchi.wuguanjia.android.utils.ToastUtil;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class MeetSignResActivity extends Activity {

    String meetId;

    MeetApi mMeetApi;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        meetId = getIntent().getStringExtra("meetId");
        mMeetApi = new MeetApi(this);
        checkIn();
    }

    private void checkIn() {
        mMeetApi.MeetCheckIn(Integer.parseInt(meetId))
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new ProgressSubscriber<BaseRequestResult<String>>(this) {

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                finish();
            }

            @Override
            public void onNext(BaseRequestResult<String> requestResult) {
                ToastUtil.showToast(requestResult.getResultMessage());
                finish();
            }
        });
    }


}
